package com.owc.service.app;

import com.owc.domain.entity.User;
import org.springframework.lang.NonNull;

import javax.security.auth.login.LoginException;
import java.math.BigDecimal;
import java.util.Optional;

public interface UserService {

    User selectUser();

    Optional<User> selectByUserName(@NonNull String username);

    Optional<User> selectByPhone(@NonNull String phone);

    Optional<User> selectById(@NonNull Long userId);

    /**
     * Check model phone is already register.
     * @param phone model phone.
     */
    boolean phoneIsRegister(@NonNull String phone);

    /**
     * Create new user.
     */
    boolean createUser(@NonNull String phone,@NonNull String password);

    /**
     * Check user pay password is OK.
     * @param userId     userId
     * @param payPassword payPwd
     */
    boolean checkPayPassword(@NonNull Long userId, @NonNull String payPassword);

    /**
     * Modify login password
     * @param currentUserId UserId
     * @param password      New password
     */
    void updatePayPassword(Long currentUserId, String password);

    /**
     * Modify pay password.
     * @param currentUserId UserId
     * @param password      New password
     */
    void updateLoginPassword(Long currentUserId, String password);

    /**
     * Get user pay password.
     * @param userId Current login user id
     * @return pay password.
     */
    String getPayPassword(Long userId);

    /**
     * Get user by address.
     * @param address wallet address.
     * @return User info
     */
    Optional<User> selectByEthAddress(@NonNull String address);

    /**
     * Get account balance.
     * @param userId  userId
     * @param tokenId  Token Id
     * @return balance
     */
	BigDecimal selectBalanceByUserId(Long userId,Long tokenId);

    /**
     * Cache user jwt sign.
     * @param userId   userId
     * @param token    jwt token
     */
	void cacheUserJwtToken(@NonNull Long userId,@NonNull String token);

    /**
     * Get user jwt token.
     * @param userId userId
     * @return token
     */
	String getUserJwtToken(@NonNull Long userId);

}
